<?
include_once("db.php");
include_once("laivid.php");
include_once("design.php");

$arr=getLaiv();
$arrid=$arr['ID'];
$sidetittel=$arr['Tittel']." - Dokumenter";
include("top.php");

headline("Dokumenter");

if (time > strftime($arr['Roller_release'])) {
	//roller-release er passert
	$sql = "SELECT * FROM Dokumenter WHERE LaivID=$arrid AND (Offentlig=1 OR Offentlig_etterlaiv=1)";
	$dokumenter = mysql_query($sql);
} else {
	//roller-release er ikke passert
	$sql = "SELECT * FROM Dokumenter WHERE LaivID=$arrid AND Offentlig=1";
	$dokumenter = mysql_query($sql);
}

if (mysql_num_rows($dokumenter)) {
	$tekst="<table class=\"liste\">\n";
	while ($dok = mysql_fetch_assoc($dokumenter)) {
		$sz = (float)$dok['str'];
		$szstr=round($sz/1024, 2);
		$tekst .= "<tr>\n";
		$tekst .= "<td>".$dok['beskrivelse']."</td>\n";
		$tekst .= "<td>$szstr kB</td>\n";
		$tekst .= "<td><a href=\"nettsvar_lastned.php?id={$dok['ID']}\">[last ned]</a></td>\n";
		$tekst .= "</tr>\n";
	}
	$tekst.="</table>\n";
} else {
	$tekst="<p>Ingen tilgjengelige dokumenter for denne laiven.</p>\n";
}

text($tekst, false);	

include("bottom.php");
?>
